class Solution {
public:
    int singleNumber(vector<int>& nums) {
        map<int, int> map1;
        for(int n : nums){
            if(map1.find(n) == map1.end())
                map1.insert(make_pair(n, 1)); 

            else
                map1[n] += 1;  
        }

        for(auto i=map1.begin(); i!=map1.end(); ++i){
            if(i->second == 1) 
                return i->first;
        }
        return 0;
        }
};
